@import '../custom.less';
@import './vars.less';

@drawer-prefix-cls: ~'@{css-prefix}drawer';

.@{drawer-prefix-cls} {
  .component-css-vars-drawer();

  .@{drawer-prefix-cls}__mask {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;

    &.show-bg-color {
      background-color: var(--ti-drawer-mask-bg-color);
    }
  }

  .@{drawer-prefix-cls}__main {
    position: fixed;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-color: #e8ebef;
    border-style: solid;
    box-shadow: var(--ti-drawer-shadow);
    overflow: hidden;

    &.drag-effects {
      transition-timing-function: linear;
      transition-duration: 200ms;
      transition-property: all;
    }

    &.is-left,
    &.is-right {
      height: 100%;
    }

    &.is-top,
    &.is-bottom {
      max-height: 100%;
    }

    &.is-right {
      top: 0;
      right: 0;
      border-left-width: 0.5px;
      border-radius: var(--ti-drawer-radius) 0 0 var(--ti-drawer-radius);

      .@{drawer-prefix-cls}__drag-bar {
        left: -4px;
      }
    }

    &.is-left {
      top: 0;
      left: 0;
      border-right-width: 0.5px;
      border-radius: 0 var(--ti-common-border-radius-2) var(--ti-common-border-radius-2) 0;

      .@{drawer-prefix-cls}__drag-bar {
        right: -4px;
      }
    }

    &.is-top {
      top: 0;
      left: 0;
      border-bottom-width: 0.5px;
      border-radius: 0 0 var(--ti-common-border-radius-2) var(--ti-common-border-radius-2);
    }

    &.is-bottom {
      bottom: 0;
      left: 0;
      border-top-width: 0.5px;
      border-radius: var(--ti-common-border-radius-2)  var(--ti-common-border-radius-2) 0 0;
    }

    .@{drawer-prefix-cls}__drag-bar {
      position: absolute;
      top: 0;
      width: 0.5rem;
      height: 100%;
      cursor: e-resize;
    }

    .@{drawer-prefix-cls}__box {
      flex: auto;
      flex-direction: column;
      max-height: 100%;
      overflow: hidden;
      display: flex;

      .@{drawer-prefix-cls}__header,
      .@{drawer-prefix-cls}__footer {
        margin-left: var(--ti-drawer-padding-left);
        margin-right: var(--ti-drawer-padding-right);
      }

      .@{drawer-prefix-cls}__header-wrapper {
        flex: none;

        .@{drawer-prefix-cls}__headerbtn {
          border: none;
          outline: none;
          background: none;
          padding: 0;
          line-height: 1;
          position: absolute;
          top: calc(
            var(--ti-drawer-btn-position-top) - (var(--ti-drawer-btn-height) - var(--ti-drawer-close-icon-size)) / 2
          );
          right: calc(
            var(--ti-drawer-btn-position-right) - (var(--ti-drawer-btn-width) - var(--ti-drawer-close-icon-size)) / 2
          );
          cursor: pointer;
          height: var(--ti-drawer-btn-height);
          width: var(--ti-drawer-btn-width);

          &:hover {
            background-color: var(--ti-drawer-btn-background-color-hover);
            border-radius: var(--ti-drawer-btn-border-radius);
          }

          & + .@{drawer-prefix-cls}__headerbtn {
            margin-left: 8px;
          }

          .@{drawer-prefix-cls}__close {
            font-size: var(--ti-drawer-close-icon-size);
            fill: var(--ti-drawer-close-icon-color);
          }
        }

        .@{drawer-prefix-cls}__header {
          padding: var(--ti-drawer-header-padding-top) var(--ti-drawer-header-padding-right)
            var(--ti-drawer-header-padding-bottom) var(--ti-drawer-header-padding-left);
          background: var(--ti-drawer-bg-color);
          display: flex;
          justify-content: space-between;
          align-items: center;
          border-bottom: 1px solid var(--ti-drawer-divider-border-color);

          .@{drawer-prefix-cls}__title {
            text-align: left;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: var(--ti-drawer-head-title-font-size);
            color: var(--ti-drawer-head-title-text-color);
            font-weight: var(--ti-drawer-head-title-font-weight);
          }

          .@{drawer-prefix-cls}__header-left {
            max-width: 80%;
            display: flex;
            align-items: center;
            padding-right: 16px;

            .@{drawer-prefix-cls}__help-icon {
              width: var(--ti-drawer-help-icon-width-height);
              height: var(--ti-drawer-help-icon-width-height);
              margin-left: var(--ti-drawer-help-icon-margin-left);
              fill: var(--ti-drawer-help-icon-color);
            }
          }

          .@{drawer-prefix-cls}__header-right {
            justify-content: flex-end;
            align-items: center;
            flex: 1;
            display: flex;
          }
        }
      }

      .@{drawer-prefix-cls}__body {
        flex: auto;
        overflow: auto;
        padding-left: var(--ti-drawer-padding-left);
        padding-right: var(--ti-drawer-padding-right);
        border-bottom: 1px solid var(--ti-drawer-divider-body-border-color);
      }

      .@{drawer-prefix-cls}__footer {
        flex: none;
        display: flex;
        align-items: center;
        justify-content: var(--ti-drawer-footer-justify-content);
        padding: var(--ti-drawer-footer-padding-top) var(--ti-drawer-footer-padding-right)
          var(--ti-drawer-footer-padding-bottom) var(--ti-drawer-footer-padding-left);
        border-top: 1px solid var(--ti-drawer-divider-footer-border-color);


        .@{drawer-prefix-cls}__confirm-btn {
          order: 0;

          &.reverse {
            margin-left: var(--ti-drawer-divider-footer-button-margin-left);
            order: 1;
          }
        }

        .@{drawer-prefix-cls}__cancel-btn {
          margin-left: var(--ti-drawer-divider-footer-button-margin-left);
          order: 1;

          &.reverse {
            margin-left: 0;
            order: 0;
          }
        }
      }
    }
  }
}

.drawer-slide-right-enter-active {
  animation: slideRight 0.3s linear;
}

.drawer-slide-right-leave-active {
  animation: slideRightout 0.3s linear;
}

@keyframes slideRight {
  0% {
    opacity: 0;
    transform: translateX(100%);
  }

  50% {
    opacity: 0.6;
    transform: translateX(50%);
  }

  100% {
    opacity: 1;
    transform: translateX(0%);
  }
}

@keyframes slideRightout {
  0% {
    opacity: 1;
    transform: translateX(0%);
  }

  50% {
    opacity: 0.6;
    transform: translateX(50%);
  }

  100% {
    opacity: 0;
    transform: translateX(100%);
  }
}

.drawer-slide-left-enter-active {
  animation: slideLeft 0.3s linear;
}

.drawer-slide-left-leave-active {
  animation: slideLeftout 0.3s linear;
}

@keyframes slideLeft {
  0% {
    opacity: 0;
    transform: translateX(-100%);
  }

  50% {
    opacity: 0.6;
    transform: translateX(-50%);
  }

  100% {
    opacity: 1;
    transform: translateX(0%);
  }
}

@keyframes slideLeftout {
  0% {
    opacity: 1;
    transform: translateX(0%);
  }

  50% {
    opacity: 0.6;
    transform: translateX(-50%);
  }

  100% {
    opacity: 0;
    transform: translateX(-100%);
  }
}

.drawer-slide-bottom-enter-active {
  animation: slideBottom 0.3s linear;
}

.drawer-slide-bottom-leave-active {
  animation: slideBottomout 0.3s linear;
}

@keyframes slideBottom {
  0% {
    opacity: 0;
    transform: translateY(100%);
  }

  50% {
    opacity: 0.6;
    transform: translateY(50%);
  }

  100% {
    opacity: 1;
    transform: translateY(0%);
  }
}

@keyframes slideBottomout {
  0% {
    opacity: 0;
    transform: translateY(0%);
  }

  50% {
    opacity: 0.6;
    transform: translateY(50%);
  }

  100% {
    opacity: 1;
    transform: translateY(100%);
  }
}

.drawer-slide-top-enter-active {
  animation: slideTop 0.3s linear;
}

.drawer-slide-top-leave-active {
  animation: slideTopout 0.3s linear;
}

@keyframes slideTop {
  0% {
    opacity: 0;
    transform: translateY(-100%);
  }

  50% {
    opacity: 0.6;
    transform: translateY(-50%);
  }

  100% {
    opacity: 1;
    transform: translateY(0%);
  }
}

@keyframes slideTopout {
  0% {
    opacity: 0;
    transform: translateY(0%);
  }

  50% {
    opacity: 0.6;
    transform: translateY(-50%);
  }

  100% {
    opacity: 1;
    transform: translateY(-100%);
  }
}

.drawer-fade-enter-active {
  animation: drawer-fade-in 0.3s linear;
}

.drawer-fade-leave-active {
  animation: drawer-fade-out 0.3s linear;
}

@keyframes drawer-fade-in {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes drawer-fade-out {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}
